package com.sgb.kjwl.view.ui.adapter.transport;

import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.CarInfoListEntity;
import com.sgb.kjwl.utils.NumberUtil;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class CarInfoAdapter extends BaseQuickAdapter<CarInfoListEntity, BaseViewHolder> {


    public CarInfoAdapter(@Nullable List<CarInfoListEntity> data) {
        super(R.layout.item_car_info, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, CarInfoListEntity item) {
        StringBuilder builder = new StringBuilder();
        if (!TextUtils.isEmpty(item.getCarTypeName())) {
            builder.append(item.getCarTypeName()).append("/");
        }

        if (!TextUtils.isEmpty(item.getCarLenName())) {
            builder.append("车长" + item.getCarLenName());
        }
        if (item.getWeight() != null) {
            builder.append("/");
            builder.append(NumberUtil.trim0(item.getWeight()));
            builder.append("吨");
        }
        holder.setText(R.id.license_plate_number, item.getCarNumber())
                .setText(R.id.car_info, builder.toString())
                .setText(R.id.address, item.getDetailAddress());
    }
}